summaryrefslogtreecommitdiff
path: root/app/[lng]/evcp/(evcp)/(procurement)/bid/[id]/items/page.tsx
blob: 5b686a1c158f825d597c39b0d212cbb6368403c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { notFound } from 'next/navigation'
import { getBiddingById } from "@/lib/bidding/service"
import { Bidding } from "@/db/schema/bidding"
import { Button } from "@/components/ui/button"
import { ArrowLeft } from "lucide-react"
import Link from "next/link"
import { BiddingItemsEditor } from "@/components/bidding/manage/bidding-items-editor"
import { BiddingTabs } from "../bidding-tabs"

// 메타데이터 생성
export async function generateMetadata({ params }: { params: Promise<{ lng: string; id: string }> }) {
  const { lng, id } = await params
  const parsedId = parseInt(id)
  if (isNaN(parsedId)) return { title: '입찰 품목 관리' }

  try {
    const bidding = await getBiddingById(parsedId)
    return {
      title: bidding ? `${bidding.title} - 입찰 품목 관리` : '입찰 품목 관리',
    }
  } catch {
    return { title: '입찰 품목 관리' }
  }
}

interface PageProps {
  params: Promise<{ lng: string; id: string }>
}

export default async function BiddingItemsPage({ params }: PageProps) {
  const { lng, id } = await params
  const parsedId = parseInt(id)

  if (isNaN(parsedId)) {
    notFound()
  }

  const bidding: Bidding | null = await getBiddingById(parsedId)

  if (!bidding) {
    notFound()
  }

  return (
    <div className="container py-6 space-y-6">
      {/* 헤더 */}
      <div className="flex justify-between items-center">
        <div className="flex items-center gap-4">
          <div>
            <h1 className="text-3xl font-bold tracking-tight">
              입찰 품목 관리
            </h1>
            <p className="text-muted-foreground mt-2">
              입찰 No. {bidding.biddingNumber ?? ""} - {bidding.title}
            </p>
          </div>

        </div>
        <Link href={`/${lng}/evcp/bid/${id}`} passHref>
          <Button variant="outline" className="flex items-center">
            <ArrowLeft className="mr-2 h-4 w-4" />
            입찰 관리로 돌아가기
          </Button>
        </Link>
      </div>

      {/* 탭 네비게이션 */}
      <div>
        <BiddingTabs id={id} />
      </div>

      {/* 입찰 품목 에디터 */}
      <BiddingItemsEditor biddingId={parsedId} />
    </div>
  )
}